# -*- coding: UTF-8 -*-

import sys
import os
import urllib
import bs4
import argparse
import time

from urllib.parse import urlparse

from bs4 import BeautifulSoup

# http://www.sifangbobo.info/html/part/index50.html, 2-139
# http://www.sifangbobo.info/html/part/index51.html, 2-83
# http://www.sifangbobo.info/html/part/index55.html, 2-135
# http://www.sifangbobo.info/html/part/index57.html, 2-54
# http://www.sifangbobo.info/html/part/index59.html, 2-54
def links_sfbb():
    urlList = []
    
    startUrl = 'http://www.sifangbobo.info/html/part/index50.html'
    urlList.append(startUrl)
    for i in range(2,140):        
        link = 'index50_%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url)

    startUrl = 'http://www.sifangbobo.info/html/part/index51.html'
    urlList.append(startUrl)
    for i in range(2,84):        
        link = 'index51_%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url)
        
    startUrl = 'http://www.sifangbobo.info/html/part/index55.html'
    urlList.append(startUrl)
    for i in range(2,136):
        link = 'index55_%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url)
    
    startUrl = 'http://www.sifangbobo.info/html/part/index57.html'
    urlList.append(startUrl)    
    for i in range(2,55):
        link = 'index57_%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url)
    
    startUrl = 'http://www.sifangbobo.info/html/part/index59.html'
    urlList.append(startUrl) 
    for i in range(2,55):
        link = 'index59_%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url)        

    f = open('sfbb.list', 'a')
    for eachUrl in urlList:
        f.write(eachUrl + '\n')
    f.close()

# http://www.911bpian.com/list/book-50-1.html, 1-112
def links_911bpian():
    urlList = []
    startUrl = 'http://www.911bpian.com/list/book-50-1.html'
    for i in range(1,113):
        link = 'book-50-%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url)

    for i in range(1,108):
        link = 'book-51-%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url)
        
    for i in range(1,113):
        link = 'book-52-%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url)
        
    for i in range(1,63):
        link = 'book-55-%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url)
        
    for i in range(1,46):
        link = 'book-56-%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url)        

    for i in range(1,95):
        link = 'book-59-%i'%i + '.html'
        url = urllib.parse.urljoin(startUrl, link)
        urlList.append(url) 

    f = open('911bpian.list', 'a')
    for eachUrl in urlList:
        f.write(eachUrl + '\n')
    f.close()
    
if __name__ == '__main__':
    
    links_sfbb()
